<?php
	namespace app\controllers\test_study;
	use yii\web\Controller;
	use app\models\test_study\orders;
	use app\models\test_study\customers;
	class SqlforeignController extends Controller{
		public function actionIndex(){
			$customer = customers::find()->where(['name'=>'zhangsan'])->one();
			//hasMany 用于关联 其他表格，参数一为对应表格的model，参数二为对应表格的值对本对象的值
			//$orders = $customer->hasMany('app\models\test_study\orders',['cus_id'=>'id'])->all();
			//效果同上
			//$orders = $customer->hasMany(orders::className(),['cus_id'=>'id'])->all();
			


			//$orders = $customers->getorders();
			$orders = $customer->orders;//其实是调用getorders()方法,函数别添加all()
			$orders = orders::find()->where(['id'=>'1'])->one();
			$customer = $orders->customers;
			print_R($orders);
		}
	}
?>